<html>
<head><meta charset="utf-8"><title>try_trait_v2: 2nd attempt · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html">try_trait_v2: 2nd attempt</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225444545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225444545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225444545">(Feb 07 2021 at 04:27)</a>:</h4>
<p>The rework is about ready to be pushed: <a href="https://gist.github.com/scottmcm/70a0b1d9c0bf3c33e8d87423bd6c2d63">https://gist.github.com/scottmcm/70a0b1d9c0bf3c33e8d87423bd6c2d63</a></p>
<p>If anyone feels like giving it a once-over for things that are still unclear or typos, I'd appreciate it.  I'll probably push it to the PR tomorrow.</p>
<p>(And ping <span class="user-mention" data-user-id="220273">@Jane Lusby</span> as requested.)</p>
<p>Previous conversations:<br>
<a href="#narrow/stream/213817-t-lang/topic/First.20draft.3A.20A.20new.20.60Try.60.20RFC">https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/First.20draft.3A.20A.20new.20.60Try.60.20RFC</a><br>
<a href="#narrow/stream/213817-t-lang/topic/Design.20meeting.202021-01-13.3A.20try_trait_v2">https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Design.20meeting.202021-01-13.3A.20try_trait_v2</a></p>



<a name="225445245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225445245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225445245">(Feb 07 2021 at 04:52)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="225445246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225445246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225445246">(Feb 07 2021 at 04:52)</a>:</h4>
<p>Ty</p>



<a name="225445256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225445256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225445256">(Feb 07 2021 at 04:53)</a>:</h4>
<p>I can't help but laugh at that title</p>



<a name="225445257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225445257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225445257">(Feb 07 2021 at 04:53)</a>:</h4>
<p>V2 second attempt</p>



<a name="225445294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225445294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225445294">(Feb 07 2021 at 04:54)</a>:</h4>
<p>Big semver energy</p>



<a name="225445704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225445704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225445704">(Feb 07 2021 at 05:09)</a>:</h4>
<p><code>try_trait_v2ex</code> here we come.  Though I suppose this is more like the 5th design for this area, really...</p>



<a name="225450353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225450353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225450353">(Feb 07 2021 at 07:28)</a>:</h4>
<p><code>try_trait_v2_final_final</code></p>



<a name="225450753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225450753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225450753">(Feb 07 2021 at 07:41)</a>:</h4>
<p>TeX style versioning <span aria-label="grinning" class="emoji emoji-1f600" role="img" title="grinning">:grinning:</span></p>



<a name="225458041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225458041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gwaihir Thorondorsen <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225458041">(Feb 07 2021 at 10:58)</a>:</h4>
<p>Minor nits: there are some random/lingering/unexplained references to <code>Try2021</code> instead of <code>Try</code>; the proposed <code>try_find</code> implementation (more precisely, the <code>check</code> inner function) uses an undefined <code>ControlFlow::CONTINUE</code> constant (whose definition is obvious, granted).</p>



<a name="225472771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225472771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225472771">(Feb 07 2021 at 16:54)</a>:</h4>
<p>This "final" proposal looks so nice <span aria-label="heart eyes" class="emoji emoji-1f60d" role="img" title="heart eyes">:heart_eyes:</span> ! Nothing to say (besides the typo nits mentioned above <span aria-label="point up" class="emoji emoji-1f446" role="img" title="point up">:point_up:</span>) it's <span aria-label="ok" class="emoji emoji-1f44c" role="img" title="ok">:ok:</span> ; I'd just suggest one minor pedagogical improvement: after having gone in detail to write the implementation of <code>try_fold</code>, I think there is then a nice opportunity there to talk about / introduce the unsugaring of <code>?</code>, even if it is redundant with the following reference-level explanation <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="225473602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225473602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225473602">(Feb 07 2021 at 17:12)</a>:</h4>
<p>In the "Implementing Try for a non-generic type" section, there is an example of splitting a <code>u32</code> into <code>()</code> + <code>NonZeroU32</code> where <code>0</code> is the success case. But what if the success case is something more complicated, for example I want even numbers to be successes and odd numbers to be failures? In that case Rust doesn't have any handy built in type, so I might use <code>u32</code> -&gt; <code>u32</code> + <code>u32</code> for the two types, but now we have a problem when recombining them because there are invalid values in the state. I guess one would want the <code>from_residual(OddU32) -&gt; u32</code> to be something like</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">from_residual</span><span class="p">(</span><span class="n">x</span>: <span class="nc">OddU32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">u32</span> <span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">if</span><span class="w"> </span><span class="n">x</span><span class="p">.</span><span class="mi">0</span><span class="w"> </span><span class="o">%</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span><span class="p">.</span><span class="mi">0</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">hint</span>::<span class="n">unreachable_unchecked</span><span class="p">()</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>but can this be used in a safe <code>Try</code> trait? (Assume that one wants to assert the oddness to the compiler here because it's using it to perform heroic optimizations.)</p>



<a name="225473609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225473609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225473609">(Feb 07 2021 at 17:12)</a>:</h4>
<p>Am I the only one who keeps being confused by the argument order in <code>ControlFlow&lt;B, C&gt;</code>? I guess it has to be that way due to the <code>C=()</code>, but the table nicely shows he asymmetry with <code>Result</code> where it's the first type that is returned by <code>?</code></p>



<a name="225473884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225473884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225473884">(Feb 07 2021 at 17:19)</a>:</h4>
<p>Also, <a href="https://gist.github.com/scottmcm/70a0b1d9c0bf3c33e8d87423bd6c2d63#why-fromtryresidual-is-the-supertrait">in this section</a>, it says</p>
<blockquote>
<p>Also, it allows Try to bound both its associated types without causing a cycle.</p>
</blockquote>
<p>But there are no bounds on those associated types?<br>
<del>(I am trying to figure out why <code>Try</code> and <code>FromTryResidual</code> are two separate traits, since their signatures makes it look like implementing one requires implementing the other -- as a supertrait in one direction, and due to <code>Self as Try</code> in the other direction.)</del> EDIT: never mind that last part, that's just the default, so when overriden it can simply be ignored.</p>



<a name="225473962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225473962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225473962">(Feb 07 2021 at 17:20)</a>:</h4>
<p>a <code>Try2021</code> trait appears in 2 places, is that a leftover from some earlier version?</p>



<a name="225474280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225474280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225474280">(Feb 07 2021 at 17:28)</a>:</h4>
<p>Thanks <span class="user-mention" data-user-id="369545">@Gwaihir Thorondorsen</span>! I'll go fix those.</p>
<p><code>Try2021</code> is me being bad at fixing up things after I've copied it from the prototype implementation (where both versions of Try exist for bootstrapping simplicity)</p>



<a name="225474554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225474554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225474554">(Feb 07 2021 at 17:34)</a>:</h4>
<p>The last section on <code>yeet</code> was confusing to me without the context for what <code>yeet</code> is supposed to do</p>



<a name="225474570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225474570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225474570">(Feb 07 2021 at 17:35)</a>:</h4>
<p>Is this <code>throw</code>?</p>



<a name="225474777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225474777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225474777">(Feb 07 2021 at 17:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/225474570">said</a>:</p>
<blockquote>
<p>Is this <code>throw</code>?</p>
</blockquote>
<p>Yes.  See the link in the summary to <a href="https://twitter.com/josh_triplett/status/1248658754976927750">https://twitter.com/josh_triplett/status/1248658754976927750</a></p>
<div class="inline-preview-twitter"><div class="twitter-tweet"><a href="https://twitter.com/josh_triplett/status/1248658754976927750"><img class="twitter-avatar" src="https://pbs.twimg.com/profile_images/1160249970215096321/a6xs3OoG_normal.jpg"></a><p><a href="https://twitter.com/yaahc_">@yaahc_</a> <a href="https://twitter.com/rustlang">@rustlang</a> You've also inspired a new placeholder to facilitate discussion. For early-exit-with-error syntax, instead of saying "fail, raise, throw, etc", I'm going to just write `yeet err;` as a neutral placeholder. Thanks!</p><span>- Josh Triplett (@josh_triplett)</span></div></div>



<a name="225475443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225475443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225475443">(Feb 07 2021 at 17:58)</a>:</h4>
<p>Perhaps something of that twitter post should appear in the RFC, for folks who don't read twitter</p>



<a name="225475455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225475455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225475455">(Feb 07 2021 at 17:59)</a>:</h4>
<p>A reference to  "fail, raise, throw, etc" should be sufficient</p>



<a name="225475466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225475466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225475466">(Feb 07 2021 at 17:59)</a>:</h4>
<p>or "early-exit-with-error" for that matter</p>



<a name="225475598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225475598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225475598">(Feb 07 2021 at 18:02)</a>:</h4>
<p>it would be pretty funny if <code>yeet</code> became the actual choice of keyword :)</p>



<a name="225477180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225477180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225477180">(Feb 07 2021 at 18:37)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">FromTryResidual</span><span class="o">&lt;</span><span class="n">Residual</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&lt;</span><span class="bp">Self</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">Try</span><span class="o">&gt;</span>::<span class="n">Residual</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="sd">/// Recreate the `Try` type from a related residual</span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">from_residual</span><span class="p">(</span><span class="n">x</span>: <span class="nc">Residual</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>How does this typecheck without a <code>Self: Try</code> bound?</p>



<a name="225477309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225477309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225477309">(Feb 07 2021 at 18:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/225477180">said</a>:</p>
<blockquote>
<p>How does this typecheck without a <code>Self: Try</code> bound?</p>
</blockquote>
<p>The bound is checked when you actually use it -- if you try to <code>impl FromTryResidual for SomethingNotTry</code> then you'll get a typecheck error on the default you're implicitly using.  But you can <code>impl FromTryResidual&lt;Foo&gt; for SomethingNotTry</code> without triggering that because you didn't use it.</p>



<a name="225477365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225477365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225477365">(Feb 07 2021 at 18:41)</a>:</h4>
<p>(I didn't know that 3 months ago.)</p>



<a name="225477546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225477546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225477546">(Feb 07 2021 at 18:44)</a>:</h4>
<p>I'm surprised (for probably the same reason as 3-months-ago you), I thought that rust tried to avoid "post-monomorphization errors" (not an exact match to this) where the text is not checked until time of use</p>



<a name="225477750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225477750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225477750">(Feb 07 2021 at 18:48)</a>:</h4>
<p>I think it's slightly less bad than that, because it needs the <code>as Try</code> -- if it were just <code>= Self::Blah</code> then that could have been typo'd, but with <code>&lt;Self as Try&gt;::Yolo</code> it'll fail to compile because that associated type doesn't exist.</p>
<p>So I think of it as being like specialization.</p>



<a name="225480187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225480187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225480187">(Feb 07 2021 at 19:43)</a>:</h4>
<p>Thanks, all!  I've updated the gist with some fixes.  I'll push it to github soon.</p>
<p><span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span> Added a final <code>simple_try_fold</code> using <code>?</code>; good idea.  Brings it nicely back to looking like the <code>simple_fold</code> again.</p>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> I've added a section about <code>C = ()</code> referencing some of the history behind it.  I'll admit I've stumbled on the order sometimes, but <code>ControlFlow&lt;T&gt;</code> is just so much more common than needing non-unit <code>C</code> that I think it's worth it.</p>



<a name="225480392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225480392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225480392">(Feb 07 2021 at 19:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/225473602">said</a>:</p>
<blockquote>
<p>but can this be used in a safe <code>Try</code> trait?</p>
</blockquote>
<p>I think this is the standard "do you make the newtype trusted or not" question.  If <code>OddU32</code> has a safe "unchecked" constructor, then no.  But if the only safe constructor does checking and the "unchecked" constructor requires <code>unsafe</code> to call, then you can.  Basically you need to delegate the proof obligation to the parameter to be able to rely on an invariant in an otherwise-safe method.</p>
<p>So if the <code>Try::Output</code> type is a plain <code>u32</code> then you can't rely on it being less than 2³¹.  But if you instead make a <code>u31</code> newtype with appropriate checking you could (even if the layout code wouldn't know about that).</p>



<a name="225482232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225482232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225482232">(Feb 07 2021 at 20:32)</a>:</h4>
<p>I see an inconsistency and I'm not sure if it has some semantic importance or not. For the proposed impl on Result, there's:</p>
<div class="codehilite"><pre><span></span><code>impl&lt;T, E&gt; ops::Try for Result&lt;T, E&gt; {
    type Residual = Result&lt;!, E&gt;;
// snip
impl&lt;T, E, F: From&lt;E&gt;&gt; ops::FromTryResidual&lt;Result&lt;!, E&gt;&gt; for Result&lt;T, F&gt; {
    fn from_residual(x: Result&lt;!, E&gt;) -&gt; Self {
</code></pre></div>
<p>Yet for the proposed impl on Option there's:</p>
<div class="codehilite"><pre><span></span><code>impl&lt;T&gt; ops::Try for Option&lt;T&gt; {
    type Residual = Option&lt;!&gt;;
// snip
impl&lt;T&gt; ops::FromTryResidual for Option&lt;T&gt; {
    fn from_residual(x: &lt;Self as ops::Try&gt;::Residual) -&gt; Self {
</code></pre></div>
<p>Is it important that the latter makes use of the Residual associated type, but not the former? Frankly my mind is kind of blown that this sort of circular reference is even allowed :P</p>
<p>While we're at it, and maybe I'm missing the point somehow, but why is Residual both an input type on FromTryResidual and an associated type on Try? Would some use case be prevented if it were just an associated type on FromTryResidual?</p>



<a name="225482622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225482622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225482622">(Feb 07 2021 at 20:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256342">bstrie</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/225482232">said</a>:</p>
<blockquote>
<p>Is it important that the latter makes use of the Residual associated type, but not the former? Frankly my mind is kind of blown that this sort of circular reference is even allowed :P</p>
</blockquote>
<p>It's not important that the impl for <code>Option</code> makes use of the associated type.  It could just say <code>Option&lt;!&gt;</code> and things would work fine.  (I originally wrote it as <code>Self::Residual</code>, but that didn't compile for reasons, so I probably should have just written out <code>Option&lt;!&gt;</code> instead of the <code>&lt;as Try&gt;</code> dance.)</p>
<p>The impl for <code>Result</code>, however, cannot use the associated type because of the <code>E</code> vs <code>F</code> difference -- it's a generic impl so it's accepting <code>Result&lt;!, E where F: From&lt;E&gt;&gt;</code>, whereas the associated type would just be <code>Result&lt;!, F&gt;</code>.  That's also why it needed to specify the generic parameter on the <code>FromTryResidual</code> trait instead.</p>



<a name="225482871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225482871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225482871">(Feb 07 2021 at 20:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256342">bstrie</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/225482232">said</a>:</p>
<blockquote>
<p>While we're at it, and maybe I'm missing the point somehow, but why is Residual both an input type on FromTryResidual and an associated type on Try? Would some use case be prevented if it were just an associated type on FromTryResidual?</p>
</blockquote>
<p>The distinction here is the difference between what come out from <code>branch</code> (<code>::Residual</code>) and which residuals can be converted into this type (<code>&lt;Residual&gt;</code>).</p>
<p>(That doesn't feel like a great answer, sorry, but I'm having trouble phrasing a better one.)</p>



<a name="225482981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225482981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225482981">(Feb 07 2021 at 20:49)</a>:</h4>
<p>All <code>Try</code> types must support recreating themselves them their own residual (hence the <code>Try: FromTryResidual&lt;Self::Residual&gt;</code> bound) but they can choose to accept more things as well, if they wish.</p>



<a name="225483920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225483920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225483920">(Feb 07 2021 at 21:10)</a>:</h4>
<p>Ok, and by "they can choose to accept more things" you mean they would achieve that by implementing just FromTryResidual, such as shown for the accidental Option interconversion shim? I guess I was confused by thinking that in all instances that every <code>Try::Residual</code> and its corresponding <code>FromTryResidual&lt;Residual&gt;</code> must refer to the exact same Residual type, but I guess looking at the <code>?</code> desugaring that by the time you call from_residual that you're past the point of caring about what gets returned from branch, so it all just works out? If my understanding happens to be correct here, then maybe it would be better if Residual were named differently in these two traits, so as to avert this conflation?</p>



<a name="225484422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225484422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225484422">(Feb 07 2021 at 21:20)</a>:</h4>
<p>Yeah, the <code>?</code> desugaring gets the type of the returned value from context, so it can do error conversion.  (The "future" section has a discussion about a different possible desugaring, using an additional trait, that wouldn't be contextual, but we can't use that in the currently-stable <code>?</code> situations because of those error-conversions.)</p>
<p>I don't know if it should have a different name.  It's expected to be <em>something</em>'s <code>::Residual</code> type, just maybe not <em><code>Self</code>'s</em>.</p>
<p>I'm definitely open to changing any of the identifiers, though.  I think every single one got renamed in this revision, which is good evidence that it's unlikely that the current names are optimal...</p>



<a name="225484518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225484518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225484518">(Feb 07 2021 at 21:23)</a>:</h4>
<p>I do actually think the current names are overall pretty good, this RFC is much more readable than the previous one with Bubble and such :) my only naming-related quibble is that FromTryResidual::from_residual not being FromResidual::from_residual or FromTryResidual::from_try_residual. I'd probably prefer the former if only because "FromTry" doesn't have all that much to do with "TryFrom"...</p>



<a name="225485020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225485020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225485020">(Feb 07 2021 at 21:32)</a>:</h4>
<p>Yeah, I went through some absolutely terrible names like <code>type Residual: IntoTry&lt;Self&gt;;</code> while experimenting.  (We'd better not have <code>TryInto</code> and <code>IntoTry</code> traits <span aria-label="fear" class="emoji emoji-1f628" role="img" title="fear">:fear:</span>)</p>
<p>Good point that the trait and method names should match.  Maybe the <code>Try</code> in the name isn't that helpful any more?  <code>FromBreak</code> would have been weird, but maybe "residual" is sufficiently distinct that <code>FromResidual</code> is ok without the <code>Try</code> in the name.</p>



<a name="225485686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225485686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225485686">(Feb 07 2021 at 21:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/225475455">said</a>:</p>
<blockquote>
<p>A reference to  "fail, raise, throw, etc" should be sufficient</p>
</blockquote>
<p>Added a sentence for this in the yeet subsection.</p>



<a name="225947428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225947428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225947428">(Feb 11 2021 at 04:22)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> just finished reading the RFC, looks great</p>



<a name="225947431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225947431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225947431">(Feb 11 2021 at 04:22)</a>:</h4>
<p>Dying at the last section</p>



<a name="225947459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225947459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225947459">(Feb 11 2021 at 04:23)</a>:</h4>
<p>My one comment is that the past tense of yeet is not "yeeted", it's "yote"</p>



<a name="225947465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225947465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225947465">(Feb 11 2021 at 04:23)</a>:</h4>
<p>At least according to my friend group, lol</p>



<a name="225964361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225964361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225964361">(Feb 11 2021 at 09:12)</a>:</h4>
<p>I've seen both.</p>



<a name="225964442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225964442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225964442">(Feb 11 2021 at 09:13)</a>:</h4>
<p>"yeet", "yeeted", "yeeting", "yeeter"...</p>



<a name="225971576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/225971576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#225971576">(Feb 11 2021 at 10:26)</a>:</h4>
<p>it should follow the pattern of "meet" i.e. "yeet" "yeets" "yeeting" "yet" /s</p>



<a name="226001431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/226001431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#226001431">(Feb 11 2021 at 14:52)</a>:</h4>
<p>What's important is that we don't forget to bikeshed the bikeshed-avoidance term</p>



<a name="226001490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/226001490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#226001490">(Feb 11 2021 at 14:52)</a>:</h4>
<p><span aria-label="smirk" class="emoji emoji-1f60f" role="img" title="smirk">:smirk:</span></p>



<a name="226018647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/226018647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#226018647">(Feb 11 2021 at 16:33)</a>:</h4>
<p>it is bikesheds all the way down</p>



<a name="226029837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/226029837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#226029837">(Feb 11 2021 at 17:46)</a>:</h4>
<p>Ah, but is it "bikeshedded" or "bikeshod".</p>



<a name="226031914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/226031914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#226031914">(Feb 11 2021 at 17:59)</a>:</h4>
<p>Do a language designer's children go unbikeshod? <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="226045730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/226045730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#226045730">(Feb 11 2021 at 19:33)</a>:</h4>
<p>this thread is thoroughly beyotten</p>



<a name="226242896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/226242896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#226242896">(Feb 13 2021 at 12:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125254">kennytm</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/225971576">said</a>:</p>
<blockquote>
<p>it should follow the pattern of "meet" i.e. "yeet" "yeets" "yeeting" "yet" /s</p>
</blockquote>
<p>you say that as if expecting English to follow a pattern would make any sense...^^</p>



<a name="226258645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/226258645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#226258645">(Feb 13 2021 at 18:04)</a>:</h4>
<p>English absolutely follows the pattern of not following an expected pattern.</p>



<a name="226258664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/226258664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#226258664">(Feb 13 2021 at 18:05)</a>:</h4>
<p>It's consistently inconsistent.</p>



<a name="226728519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/226728519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#226728519">(Feb 17 2021 at 21:28)</a>:</h4>
<p>Status update after the libs meeting, I'll be doing the following:</p>
<ul>
<li>Do the <code>FromTryResidual</code> -&gt; <code>FromResidual</code> change.</li>
<li>Add a three-trait structure alternative, and unresolved question for an eventual tracking issue.</li>
<li>Add a <code>Break</code>/<code>Continue</code> naming alternative, and unresolved question for an eventual tracking issue.</li>
<li>Get my prototype implementation crater-ready.</li>
</ul>



<a name="227077886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227077886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227077886">(Feb 20 2021 at 08:49)</a>:</h4>
<p>Interesting side effect, as I look at some MIR tests: moving the <code>from</code> means one fewer function call and one fewer mir temporary per <code>?</code>.  Might actually help the overall generate-the-IR times.</p>
<p>(Apparently I broke the unsound mir opt that simplified <code>?</code>, but I don't feel too bad about that.)</p>



<a name="227125646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227125646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227125646">(Feb 20 2021 at 23:04)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/82318">Prepping a <code>try</code> build</a> found a new kind of interconversion example.  See conversation in <a href="#narrow/stream/219381-t-libs/topic/Code.20mixing.20.60Option.60.2F.60Result.60.20in.20.60.3F.60.20(RFC.233058)">https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Code.20mixing.20.60Option.60.2F.60Result.60.20in.20.60.3F.60.20(RFC.233058)</a></p>



<a name="227130260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227130260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227130260">(Feb 21 2021 at 00:38)</a>:</h4>
<p>And the first crater run is queued: <a href="https://crater.rust-lang.org/ex/pr-82318">https://crater.rust-lang.org/ex/pr-82318</a></p>



<a name="227175812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227175812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227175812">(Feb 21 2021 at 15:53)</a>:</h4>
<p>Hypee</p>



<a name="227176065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227176065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227176065">(Feb 21 2021 at 15:58)</a>:</h4>
<p>Really excited for this. I'm looking forward to doing <code>?</code>-able things.</p>



<a name="227271434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227271434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227271434">(Feb 22 2021 at 14:12)</a>:</h4>
<p>Hello people! <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span> Some days ago I felt like <code>?</code> could be more flexible and I'm really happy to see this wonderful RFC about it.</p>
<p>The only thing that I don't get is the name of the trait. It feels to me that <code>Try</code> was more appropriate in the past because its meaning was more restricted. The main reason that I see for keeping it is because people got used to call <code>?</code> as the try operator because of the macro it replaced.</p>
<p>It would be nice to find a name which could describe the meaning of the operator/new trait.</p>



<a name="227295885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227295885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227295885">(Feb 22 2021 at 16:35)</a>:</h4>
<p>After reading the RFC again, the best name I could think until now is <code>EarlyExit</code>. I read "early exit" at least two times on the RFC and I think it may shortly express the operation done by <code>?</code>.</p>
<p>No bikeshedding intended <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> just wanted to show my point of view <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="227298019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227298019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227298019">(Feb 22 2021 at 16:49)</a>:</h4>
<p><span class="user-mention" data-user-id="312608">@Eduardo Canellas</span> that's actually a good point. I had raised against <code>try</code> that there's situations (such as web routing) where the early return is "route found" and not "we hit an error"</p>



<a name="227313778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227313778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227313778">(Feb 22 2021 at 18:25)</a>:</h4>
<p><span class="user-mention" data-user-id="312608">@Eduardo Canellas</span> I'd be happy to find a new name.  No worries about <span aria-label="bike" class="emoji emoji-1f6b2" role="img" title="bike">:bike:</span><span aria-label="house" class="emoji emoji-1f3e0" role="img" title="house">:house:</span>ing; I've also started threads for that in the past for this: <a href="https://internals.rust-lang.org/t/bikeshed-a-consise-verb-for-the-operator/7289/29?u=scottmcm">https://internals.rust-lang.org/t/bikeshed-a-consise-verb-for-the-operator/7289/29?u=scottmcm</a></p>
<p>TBH, mostly I just left it as <code>Try</code> because that was the easiest thing to do in the prototype (no need to update all the <code>try_fold</code> implementations).  Though I can somewhat back-justify it with "<code>Try</code> is the trait for types used in <code>try_*</code> methods".</p>



<a name="227315070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227315070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227315070">(Feb 22 2021 at 18:34)</a>:</h4>
<p>The naming part that I find particularly hard is the conditional-ness of <code>?</code>.  A name like <code>EarlyExit</code> could also be the trait for <code>throw</code>/<code>fail</code>/<code>raise</code>/<code>yeet</code>/..., for example, since that one's <em>always</em> an early exit.</p>



<a name="227315720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227315720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227315720">(Feb 22 2021 at 18:38)</a>:</h4>
<p>Agreed that "try" is a bit overloaded as a general term, it might conjure potentially-misleading analogies to exception systems, and it's more-or-less orthogonal to the <code>TryFoo</code> traits elsewhere in std. That said, it's probably not that big a deal, since most users aren't ever probably going to directly interact with it themselves? Unless it shows up in error messages when using <code>?</code></p>



<a name="227320574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227320574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227320574">(Feb 22 2021 at 19:10)</a>:</h4>
<p>It's in the default error message for using <code>?</code> on something that doesn't support it, yes.  Though there's enough <code>rustc_on_unimplemented</code> magic going on that the error message says something like "You can only use <code>?</code> on <code>Result</code>s or <code>Option</code>s (or another type which implements <code>Try</code>)", so seeing <code>Try</code> is very much secondary.</p>
<p>I like the "<code>TryFrom</code> isn't a subtrait of <code>Try</code>" observation...</p>



<a name="227323000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227323000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227323000">(Feb 22 2021 at 19:27)</a>:</h4>
<p>I tried a few names (using Search + Replace) <a href="https://github.com/eduardocanellas/rfcs/pull/1">on a fork</a> to see what it could look like.</p>
<p>I just focused on the behavior of <code>?</code>, instead of its main usage (deal with errors). I think <code>?</code> could be very useful in scenarios which do not involve error handling (e.g. the "route found" example from <span class="user-mention" data-user-id="215333">@Florian Gilcher</span>, early returns for the happy case).</p>
<p>In short, the initial idea:</p>
<p><code>Try</code> -&gt; <code>EarlyExit</code><br>
<code>Output</code> -&gt; <code>Remainder</code> (because the value "remains" where <code>?</code> is called)<br>
<code>Residual</code> -&gt; <code>Return</code> (or something with a similar meaning)</p>
<p>I'm not familiar with other designs which could be affected/related (e.g. <code>yeet</code> family), though.</p>



<a name="227323058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227323058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227323058">(Feb 22 2021 at 19:27)</a>:</h4>
<p>I already usually call <code>?</code> the propagation operator</p>



<a name="227323068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227323068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227323068">(Feb 22 2021 at 19:27)</a>:</h4>
<p>fwiw</p>



<a name="227324291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227324291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227324291">(Feb 22 2021 at 19:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="220273">Jane Lusby</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/227323058">said</a>:</p>
<blockquote>
<p>I already usually call <code>?</code> the propagation operator</p>
</blockquote>
<p><code>Try</code> -&gt; <code>Propagate</code><br>
<code>Output</code> -&gt; <code>Remainder</code><br>
<code>Residual</code> -&gt; <code>Output</code></p>
<p>I like it <span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span></p>



<a name="227333988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227333988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Gilcher <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227333988">(Feb 22 2021 at 20:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="220273">Jane Lusby</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/227323058">said</a>:</p>
<blockquote>
<p>I already usually call <code>?</code> the propagation operator</p>
</blockquote>
<p>I like it, I defaulted to "question mark" for lack of a better name.</p>



<a name="227336456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227336456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227336456">(Feb 22 2021 at 21:00)</a>:</h4>
<p>for consistency it would be called <code>Propagate</code>, similar to how it's <code>std::ops::Add</code> and not <code>std::ops::Addition</code></p>



<a name="227338943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227338943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227338943">(Feb 22 2021 at 21:18)</a>:</h4>
<p>I tend to say "question mark" too, though I like the verb "bubble" from that bikeshed link.</p>
<p>The original <code>Try</code> RFC points out that it's <code>Add</code> and not <code>Plus</code>: <a href="https://rust-lang.github.io/rfcs/1859-try-trait.html?highlight=plus#what-to-name-the-trait">https://rust-lang.github.io/rfcs/1859-try-trait.html?highlight=plus#what-to-name-the-trait</a></p>



<a name="227339604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227339604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227339604">(Feb 22 2021 at 21:23)</a>:</h4>
<p>"bubble operator" is certainly less of a mouthful than "propagate operator", but I'm flashing back to the original try_v2 proposal and how much trouble I had understanding the terms there (which included "bubble")</p>



<a name="227363946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227363946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227363946">(Feb 23 2021 at 00:33)</a>:</h4>
<p>I like the <code>ControlFlow</code> terminology for the values, <code>Continue</code> and <code>Break</code></p>



<a name="227467822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227467822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227467822">(Feb 23 2021 at 17:17)</a>:</h4>
<p>I feel pretty strongly that calling <code>Residual</code> <code>Output</code> would be confusing</p>



<a name="227497459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227497459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227497459">(Feb 23 2021 at 20:23)</a>:</h4>
<p>I get confused with the current names because <code>Residual</code> is used to the value that is "ejected" by <code>?</code> in the RFC. To me, it looks more intuitive that the "residual" value should be the one which remains in the call site. <code>Residual</code> or <code>Remainder</code> for the one in the call site and other name for the one which is lifted.</p>



<a name="227497873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227497873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227497873">(Feb 23 2021 at 20:26)</a>:</h4>
<p>But maybe I think about <code>?</code> differently. The current names may feel okay when I just think about errors and error propagation. But I have the impression that the trait would allow more use cases besides errors, wouldn't it?</p>



<a name="227503114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227503114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227503114">(Feb 23 2021 at 21:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312608">Eduardo Canellas</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/227497459">said</a>:</p>
<blockquote>
<p>I get confused with the current names because <code>Residual</code> is used to the value that is "ejected" by <code>?</code> in the RFC. To me, it looks more intuitive that the "residual" value should be the one which remains in the call site. <code>Residual</code> or <code>Remainder</code> for the one in the call site and other name for the one which is lifted.</p>
</blockquote>
<p>this seems like a matter of perspective. you're viewing the job of <code>?</code> as primarily "ejecting the (break) value" while the continue value is the leftover. I think it's more accurate to say that unwrapping the continue value is the primary operation and that ejecting the break value is the fallback / secondary case. Or at least it is more correct in the current framing of "trying a fallible operation"</p>



<a name="227507670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227507670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227507670">(Feb 23 2021 at 21:37)</a>:</h4>
<p>So I think it has to be the side it is when coupled with <code>Output</code> -- like how <code>Not::Output</code> is the type of the value that comes out of the <code>!</code> operator, <code>Try::Output</code> is the type of the value that comes out of the <code>?</code> operator.</p>
<p>Now, it's possible they should <em>both</em> change.  Libs has asked for me to write in an alternative for that, in fact.</p>



<a name="227520446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227520446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227520446">(Feb 23 2021 at 23:04)</a>:</h4>
<p>I definitely feel that the "unwrap" value is the "primary" one</p>



<a name="227520480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227520480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227520480">(Feb 23 2021 at 23:04)</a>:</h4>
<p>however</p>



<a name="227520511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227520511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227520511">(Feb 23 2021 at 23:05)</a>:</h4>
<p>a name like <code>AbortType</code> or <code>BreakType</code> (break is not great because it's overloaded...) might clarify things</p>



<a name="227520545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227520545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227520545">(Feb 23 2021 at 23:05)</a>:</h4>
<p>I believe in some specs it's called an "abrupt exit"</p>



<a name="227521152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227521152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227521152">(Feb 23 2021 at 23:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/227520545">said</a>:</p>
<blockquote>
<p>I believe in some specs it's called an "abrupt exit"</p>
</blockquote>
<p>oo, this makes me think of "early exit"</p>



<a name="227521292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227521292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227521292">(Feb 23 2021 at 23:11)</a>:</h4>
<p><code>FromEarlyExit</code> and <code>FromKeepGoing</code> would work...</p>



<a name="227521413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227521413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227521413">(Feb 23 2021 at 23:12)</a>:</h4>
<p>"exit" has connotations of "end the whole program", though.</p>



<a name="227521422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227521422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227521422">(Feb 23 2021 at 23:12)</a>:</h4>
<p>"early return" perhaps?</p>



<a name="227521449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227521449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227521449">(Feb 23 2021 at 23:13)</a>:</h4>
<p><code>FromReturn</code>?</p>



<a name="227521486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227521486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227521486">(Feb 23 2021 at 23:13)</a>:</h4>
<p>return doesn't apply to try blocks</p>



<a name="227521509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227521509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227521509">(Feb 23 2021 at 23:13)</a>:</h4>
<p>I think I'd prefer <code>Output</code> myself for the "main name"</p>



<a name="227521523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227521523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227521523">(Feb 23 2021 at 23:13)</a>:</h4>
<p>(personally)</p>



<a name="227521586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227521586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227521586">(Feb 23 2021 at 23:14)</a>:</h4>
<p>just because I hate remembering the "special snowflake" names of associated types on various traits</p>



<a name="227526885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227526885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227526885">(Feb 24 2021 at 00:05)</a>:</h4>
<p>"output" seems more ambiguous.</p>



<a name="227526946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227526946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227526946">(Feb 24 2021 at 00:06)</a>:</h4>
<p>It could mean the early output or the continuing output.</p>



<a name="227528355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227528355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227528355">(Feb 24 2021 at 00:20)</a>:</h4>
<p>I'll contend that the conceptual "output" of the <code>?</code> operator is arguably from the perspective of the expression invoking it. In an expression invoking <code>?</code>, the output is the thing that it will get back from it, rather than the thing that might potentially end up <em>waves hands</em> somewhere else</p>



<a name="227555170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227555170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227555170">(Feb 24 2021 at 06:43)</a>:</h4>
<p>OuterOutput / InnerOutput</p>



<a name="227559347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227559347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227559347">(Feb 24 2021 at 07:37)</a>:</h4>
<p><code>OuterInput</code>/<code>InnerOutput</code> <span aria-label="smirk" class="emoji emoji-1f60f" role="img" title="smirk">:smirk:</span></p>



<a name="227578009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227578009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227578009">(Feb 24 2021 at 10:33)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/227526885">said</a>:</p>
<blockquote>
<p>"output" seems more ambiguous.</p>
</blockquote>
<p>I agree it's conceptually ambiguous. I just agree with <span class="user-mention" data-user-id="256342">@bstrie</span> and others that the "output" of an operator is the value that passes to the surrounding expressions</p>



<a name="227578018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227578018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227578018">(Feb 24 2021 at 10:33)</a>:</h4>
<p>and I think this consistency is worth maintaining</p>



<a name="227578046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227578046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227578046">(Feb 24 2021 at 10:33)</a>:</h4>
<p>in other words, I would rather have a rule I can remember across all operators</p>



<a name="227578068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227578068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227578068">(Feb 24 2021 at 10:34)</a>:</h4>
<p>then to have a less ambiguous case for this one</p>



<a name="227578179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227578179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227578179">(Feb 24 2021 at 10:34)</a>:</h4>
<p>I will admit I also don't find <code>Output</code> <em>particularly</em> unclear-- I think the <em>vast majority</em> of users are going to be writing code with <code>Result</code> in their minds when they think about <code>?</code></p>



<a name="227587269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227587269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227587269">(Feb 24 2021 at 11:59)</a>:</h4>
<p><code>Output</code> / <code>Input</code>! <code>Output</code> is the value which goes out, <code>Input</code> is the value that stays in <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="227614776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227614776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227614776">(Feb 24 2021 at 15:23)</a>:</h4>
<p>I know that this isn't useful but I think of it as <code>Happy</code> and <code>Sad</code></p>



<a name="227626234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227626234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227626234">(Feb 24 2021 at 16:22)</a>:</h4>
<p>Hey, I took some time and tried to implement a draft on the feature I was thinking for <code>?</code>: be able to easily early return in success cases too. Here's the gist: <a href="https://gist.github.com/eduardocanellas/ef1b476f776e87bdda3a8fab35912172">https://gist.github.com/eduardocanellas/ef1b476f776e87bdda3a8fab35912172</a></p>
<p>It runs fine on <span class="user-mention" data-user-id="125270">@scottmcm</span>'s branch <span aria-label="happy" class="emoji emoji-1f600" role="img" title="happy">:happy:</span> </p>
<p>As I'm a beginner here, it may have problems that I couldn't notice <span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span></p>



<a name="227627108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227627108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227627108">(Feb 24 2021 at 16:26)</a>:</h4>
<p><span class="user-mention" data-user-id="312608">@Eduardo Canellas</span> can you give the tl;dr of what I am looking at here :)</p>



<a name="227632172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227632172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227632172">(Feb 24 2021 at 16:54)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> In short, a <code>Lift</code> type (the trait I added there) is used to allow types to "lift" a value. The motivation is that I wanted to be able to propagate <code>Ok</code> instead of <code>Err</code>. Maybe the test I added in the end clarify how the usage would be. Without this code, I guess I would have to make three <code>if/match</code> in the test.</p>
<p>In the test, <code>b</code>'s return is propagated and the return of <code>test</code> is <code>Ok(42)</code>, as asserted.</p>



<a name="227634321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227634321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227634321">(Feb 24 2021 at 17:05)</a>:</h4>
<p>It's very cool that your extension is now possible!</p>



<a name="227638893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227638893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227638893">(Feb 24 2021 at 17:31)</a>:</h4>
<p>I think I see</p>



<a name="227644492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227644492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227644492">(Feb 24 2021 at 18:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312608">Eduardo Canellas</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/227626234">said</a>:</p>
<blockquote>
<p>Hey, I took some time and tried to implement a draft on the feature I was thinking for <code>?</code>: be able to easily early return in success cases too.</p>
</blockquote>
<p>Looks similar to what <span class="user-mention" data-user-id="125254">@kennytm</span> put together in <a href="https://github.com/rust-lang/rfcs/pull/3058#issuecomment-766365909">https://github.com/rust-lang/rfcs/pull/3058#issuecomment-766365909</a></p>



<a name="227645362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227645362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227645362">(Feb 24 2021 at 18:11)</a>:</h4>
<p>I'm a little worried that the error can be silently dropped, not even a <code>must_use</code> warning, but still I think it's good that folks will be able to experiment with such adapters outside of the standard library.</p>



<a name="227662082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227662082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227662082">(Feb 24 2021 at 20:01)</a>:</h4>
<p>my last bikeshed, perhaps <code>LocalOutput</code> vs <code>RemoteOutput</code>?</p>



<a name="227662168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227662168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227662168">(Feb 24 2021 at 20:02)</a>:</h4>
<p>Honestly, I'd much rather see something closer to ControlFlow's "break" and "continue" naming.</p>



<a name="227662183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227662183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227662183">(Feb 24 2021 at 20:02)</a>:</h4>
<p>(assuming those names don't change)</p>



<a name="227662247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227662247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227662247">(Feb 24 2021 at 20:02)</a>:</h4>
<p>Or <em>some</em> name that makes it incredibly obvious which one goes with which direction of control flow.</p>



<a name="227715755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227715755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227715755">(Feb 25 2021 at 04:24)</a>:</h4>
<p>How about <code>Output</code> and <code>BreakValue</code>?</p>



<a name="227741958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227741958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227741958">(Feb 25 2021 at 09:48)</a>:</h4>
<p>I think <code>BreakValue</code> sounds too much like the wrapped value</p>



<a name="227741968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227741968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227741968">(Feb 25 2021 at 09:48)</a>:</h4>
<p>but <code>BreakResidual</code> seems good</p>



<a name="227741994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227741994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227741994">(Feb 25 2021 at 09:48)</a>:</h4>
<p>or something along those lines</p>



<a name="227758389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227758389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227758389">(Feb 25 2021 at 12:25)</a>:</h4>
<p>Maybe <code>Up</code> and <code>Stay</code></p>



<a name="227778488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227778488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227778488">(Feb 25 2021 at 14:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/227077886">said</a>:</p>
<blockquote>
<p>Interesting side effect, as I look at some MIR tests: moving the <code>from</code> means one fewer function call and one fewer mir temporary per <code>?</code>.  Might actually help the overall generate-the-IR times.</p>
</blockquote>
<p>Did you by any chance try a perf run? The interpreter in rustc heavily uses <code>?</code> and suffers from its current relatively poor codegen. It would be a good testing ground.</p>



<a name="227823346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/227823346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#227823346">(Feb 25 2021 at 19:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="352985">tm</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/227778488">said</a>:</p>
<blockquote>
<p>Did you by any chance try a perf run?</p>
</blockquote>
<p>I don't think my prototype is likely to be in a place where the overall codegen is better.  It does nothing to help the core "LLVM is bad at rebuilding 2-variant enums" problem, and regresses things like the mir-opt that simplifies basic <code>?</code>s.  So while I think the HAIR-&gt;MIR will emit something slightly smaller, I doubt that right now that'd be material to a perf run.</p>



<a name="228327180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228327180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nadrieril <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228327180">(Mar 01 2021 at 23:41)</a>:</h4>
<p>Since we're bikeshedding, I liked the name <code>ShortCircuit</code> for the residual. And possibly <code>ShortCircuiting</code> for the trait too but I'm less sure it conveys what we want</p>



<a name="228646865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228646865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228646865">(Mar 03 2021 at 18:56)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> some more feedback on the try trait work</p>



<a name="228646879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228646879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228646879">(Mar 03 2021 at 18:56)</a>:</h4>
<p>though I don't think this specific complaint is specific to any changes you've made</p>



<a name="228646950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228646950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228646950">(Mar 03 2021 at 18:57)</a>:</h4>
<p>but rn I'm trying to work on this example of how I'd like to see try being used in the future, and I'm looking at it from an viewpoint of teachability</p>



<a name="228647026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647026">(Mar 03 2021 at 18:57)</a>:</h4>
<p>specifically</p>



<a name="228647032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647032">(Mar 03 2021 at 18:57)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">do_thing2</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">report</span>::<span class="nb">Result</span><span class="o">&lt;</span><span class="p">()</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">do_thing</span><span class="p">()</span><span class="o">?</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="n">report</span>::<span class="nb">Result</span>::<span class="n">from_output</span><span class="p">(())</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228647040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647040">(Mar 03 2021 at 18:57)</a>:</h4>
<p>the last line</p>



<a name="228647065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647065">(Mar 03 2021 at 18:58)</a>:</h4>
<p>I'm trying to find a way to make <code>Ok(())</code> work</p>



<a name="228647122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647122">(Mar 03 2021 at 18:58)</a>:</h4>
<p>or something that I feel will be equivalently obvious</p>



<a name="228647673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647673">(Mar 03 2021 at 19:01)</a>:</h4>
<p>I currently have this</p>



<a name="228647683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647683">(Mar 03 2021 at 19:01)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="cp">#[allow(non_snake_case)]</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">Ok</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">value</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="nb">Result</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">inner</span>: <span class="nc">StdOk</span><span class="p">(</span><span class="n">value</span><span class="p">),</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228647697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647697">(Mar 03 2021 at 19:01)</a>:</h4>
<p>seems to work</p>



<a name="228647733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647733">(Mar 03 2021 at 19:01)</a>:</h4>
<p>which gives this</p>



<a name="228647739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647739">(Mar 03 2021 at 19:01)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">do_thing2</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">report</span>::<span class="nb">Result</span><span class="o">&lt;</span><span class="p">()</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">do_thing</span><span class="p">()</span><span class="o">?</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="c1">// report::Result::from_output(())</span>
<span class="w">    </span><span class="n">report</span>::<span class="nb">Ok</span><span class="p">(())</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228647787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647787">(Mar 03 2021 at 19:01)</a>:</h4>
<p>so maybe its only an issue for implementors</p>



<a name="228647900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228647900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228647900">(Mar 03 2021 at 19:02)</a>:</h4>
<p>because I had to alias all the std Result types before introducing my own or face horrid compiler errors</p>



<a name="228648099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228648099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228648099">(Mar 03 2021 at 19:03)</a>:</h4>
<p>overall I feel like this is a strong pressure towards <code>try</code> blocks</p>



<a name="228651392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228651392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228651392">(Mar 03 2021 at 19:23)</a>:</h4>
<p>actually I think there's an easy solution here I just completely overlooked</p>



<a name="228651430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228651430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228651430">(Mar 03 2021 at 19:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="220273">Jane Lusby</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/228648099">said</a>:</p>
<blockquote>
<p>overall I feel like this is a strong pressure towards <code>try</code> blocks</p>
</blockquote>
<p>Agreed.  I previously actually moved almost all the <code>from_output</code> calls in <code>library</code> in favour of using <code>try{}</code> blocks: <a href="https://github.com/rust-lang/rust/pull/77877">https://github.com/rust-lang/rust/pull/77877</a></p>
<p>Admittedly that was to make it easier to change the desugaring, but I think it's interesting as something that might be valuable in general.</p>



<a name="228651500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228651500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228651500">(Mar 03 2021 at 19:24)</a>:</h4>
<p>yea</p>



<a name="228651820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228651820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228651820">(Mar 03 2021 at 19:26)</a>:</h4>
<p>A silly thought: <code>try{x}</code> is available on stable as <code>iter::empty().try_for_each(x, |_| unreachable!())</code>.</p>



<a name="228651988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228651988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228651988">(Mar 03 2021 at 19:27)</a>:</h4>
<p>....</p>



<a name="228652059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228652059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228652059">(Mar 03 2021 at 19:27)</a>:</h4>
<p>loool</p>



<a name="228652298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228652298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228652298">(Mar 03 2021 at 19:28)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/228651820">said</a>:</p>
<blockquote>
<p>A silly thought: <code>try{x}</code> is available on stable as <code>iter::empty().try_for_each(x, |_| unreachable!())</code>.</p>
</blockquote>
<p>almost :) doesn't have <code>break</code>!</p>



<a name="228653537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228653537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228653537">(Mar 03 2021 at 19:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="220273">Jane Lusby</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/228647900">said</a>:</p>
<blockquote>
<p>because I had to alias all the std Result types before introducing my own or face horrid compiler errors</p>
</blockquote>
<p>Is there a reason why <code>report</code> wants to provide <code>Result</code> and <code>Ok</code> rather than use distinct names?</p>



<a name="228653861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228653861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228653861">(Mar 03 2021 at 19:37)</a>:</h4>
<p>pretty happy with how this came out</p>



<a name="228653862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228653862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228653862">(Mar 03 2021 at 19:37)</a>:</h4>
<p><a href="https://gist.github.com/yaahc/c9348cca4aa34ba8bc92f41ba543919d">https://gist.github.com/yaahc/c9348cca4aa34ba8bc92f41ba543919d</a></p>



<a name="228653965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228653965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228653965">(Mar 03 2021 at 19:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/228653537">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="220273">Jane Lusby</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/228647900">said</a>:</p>
<blockquote>
<p>because I had to alias all the std Result types before introducing my own or face horrid compiler errors</p>
</blockquote>
<p>Is there a reason why <code>report</code> wants to provide <code>Result</code> and <code>Ok</code> rather than use distinct names?</p>
</blockquote>
<p>not really, It just seemed most intuitive to copy the <code>Result</code> api</p>



<a name="228654077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228654077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228654077">(Mar 03 2021 at 19:38)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">FromResidual</span><span class="o">&lt;</span><span class="nb">Result</span><span class="o">&lt;!&gt;&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="nb">Result</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">fn</span> <span class="nf">from_residual</span><span class="p">(</span><span class="n">residual</span>: <span class="nb">Result</span><span class="o">&lt;!&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="kd">let</span><span class="w"> </span><span class="n">Err2</span><span class="p">(</span><span class="n">error</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">residual</span><span class="p">;</span><span class="w"></span>
<span class="w">            </span><span class="n">Err2</span><span class="p">(</span><span class="n">error</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228654080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228654080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228654080">(Mar 03 2021 at 19:38)</a>:</h4>
<p>the good code</p>



<a name="228654126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228654126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228654126">(Mar 03 2021 at 19:39)</a>:</h4>
<p>actually shit</p>



<a name="228654129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228654129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228654129">(Mar 03 2021 at 19:39)</a>:</h4>
<p>its still Err2</p>



<a name="228654135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228654135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228654135">(Mar 03 2021 at 19:39)</a>:</h4>
<p>damnit</p>



<a name="228714955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228714955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228714955">(Mar 04 2021 at 04:28)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/228651820">said</a>:</p>
<blockquote>
<p>A silly thought: <code>try{x}</code> is available on stable as <code>iter::empty().try_for_each(x, |_| unreachable!())</code>.</p>
</blockquote>
<p>I use <code>(|| -&gt; Result&lt;_, _&gt; {Ok({ x })})()</code> a lot. Suffice it to say I'm eagerly awaiting <code>try</code> blocks on stable</p>



<a name="228735437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228735437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228735437">(Mar 04 2021 at 08:40)</a>:</h4>
<p>Likewise. As well as the async equivalent.</p>



<a name="228828659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/228828659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#228828659">(Mar 04 2021 at 18:50)</a>:</h4>
<p>Crater run 29% complete: <a href="https://crater.rust-lang.org/ex/pr-82322">https://crater.rust-lang.org/ex/pr-82322</a> <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>
<p>(This is without <code>mod sadness</code>, to see how bad an edition transition would be.  And because it would allow targeting a smaller set of crates for the "make sure it doesn't break 2015 code" run later.)</p>



<a name="229215915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/229215915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#229215915">(Mar 07 2021 at 20:34)</a>:</h4>
<p>And crater's done.  Lots of failures for things implementing <code>Try</code>, of course, but some real failures too.</p>
<p>Conversation about it is happening in <a class="stream" data-stream-id="219381" href="/#narrow/stream/219381-t-libs">#t-libs</a> : <a href="#narrow/stream/219381-t-libs/topic/Code.20mixing.20.60Option.60.2F.60Result.60.20in.20.60.3F.60.20%28RFC.233058%29/near/229215352">https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Code.20mixing.20.60Option.60.2F.60Result.60.20in.20.60.3F.60.20%28RFC.233058%29/near/229215352</a></p>
<p>(Posting here for people following this topic but maybe not that other stream.)</p>



<a name="233547843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233547843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233547843">(Apr 07 2021 at 19:31)</a>:</h4>
<p>And it's made it to FCP! <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="233577720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233577720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233577720">(Apr 07 2021 at 23:14)</a>:</h4>
<p>yay!</p>



<a name="233716447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233716447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233716447">(Apr 08 2021 at 19:44)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> I was talking to <span class="user-mention" data-user-id="224941">@Carl Lerche</span> today about some experimental designs he's been looking at and we had a scenario regarding the <code>Try</code> trait we wanted to ask about.</p>



<a name="233716573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233716573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233716573">(Apr 08 2021 at 19:45)</a>:</h4>
<p>The goal would be to have a struct that is like <code>struct Foo(io::Result&lt;usize&gt;, Buffer)</code>, where you <em>usually</em> want to do <code>foo?</code> to test the <code>Result</code> (and get out the buffer, maybe the <code>usize</code> too, I forget), but sometimes you might want to unpack manually so you can use the <code>Buffer</code> even in the case o error</p>



<a name="233716607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233716607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233716607">(Apr 08 2021 at 19:46)</a>:</h4>
<p>Do you think that would work readily enough in your design? I guess I should go poke at the traits and see how they fit</p>



<a name="233724874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233724874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Carl Lerche <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233724874">(Apr 08 2021 at 20:43)</a>:</h4>
<p>Mentioned here: <a href="https://github.com/tokio-rs/tokio-uring/pull/1/files#diff-3dc5dd454e080eb849ee5efaf79df2585fbe0a06804d69249b4c81da05a63875R208-R212">https://github.com/tokio-rs/tokio-uring/pull/1/files#diff-3dc5dd454e080eb849ee5efaf79df2585fbe0a06804d69249b4c81da05a63875R208-R212</a></p>



<a name="233731286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233731286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233731286">(Apr 08 2021 at 21:17)</a>:</h4>
<p>&lt;deleted&gt;</p>



<a name="233731319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233731319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233731319">(Apr 08 2021 at 21:17)</a>:</h4>
<p>&lt;deleted&gt;</p>



<a name="233731791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233731791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233731791">(Apr 08 2021 at 21:19)</a>:</h4>
<p>&lt;deleted&gt; don't mind me</p>



<a name="233752677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233752677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233752677">(Apr 09 2021 at 00:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/233716573">said</a>:</p>
<blockquote>
<p>The goal would be to have a struct that is like <code>struct Foo(io::Result&lt;usize&gt;, Buffer)</code>, where you <em>usually</em> want to do <code>foo?</code> to test the <code>Result</code> (and get out the buffer, maybe the <code>usize</code> too, I forget), but sometimes you might want to unpack manually so you can use the <code>Buffer</code> even in the case o error</p>
</blockquote>
<p>I think that would work fine.  With <code>struct BufResult&lt;T&gt;(io::Result&lt;T&gt;, buf::Slice);</code> you could have it split to <code>(T, buf::Slice)</code> and use <code>io::Result&lt;!&gt;</code> as the residual, if I'm understanding right.</p>



<a name="233752728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233752728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233752728">(Apr 09 2021 at 00:53)</a>:</h4>
<p>Oh, wait, it needs the slice for error returns too?  Then I guess it's <code>BufResult&lt;!&gt;</code> as the residual.</p>



<a name="233752773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/233752773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#233752773">(Apr 09 2021 at 00:54)</a>:</h4>
<p>Since that's a type with an <code>io::Error</code> and a <code>buf::Slice</code>.</p>



<a name="234358720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/234358720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#234358720">(Apr 13 2021 at 16:30)</a>:</h4>
<p>makes sense</p>



<a name="234374453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try_trait_v2%3A%202nd%20attempt/near/234374453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt.html#234374453">(Apr 13 2021 at 18:09)</a>:</h4>
<p>I suppose it's nearly identical to <code>type BufResult&lt;T, E&gt; = Result&lt;(T, buf::Slice), (E, buf::Slice)&gt;;</code>.  Would depend on how it wanted to do error conversion, since AFAIK there's no <code>(F, buf::Slice): From&lt;(E, buf::Slice)&gt; where F: From&lt;E&gt;</code>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>